package com.ThreadPool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

//线程池1
public class Pool1 {
    public static void main(String[] args) {

        ExecutorService es = Executors.newFixedThreadPool(3);//固定线程池
        //当线程数达到最大核心线程数，则加入队列等待有空闲线程时再执行
//        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor();
        es.execute(new MyThread());
        es.execute(new MyThread());

        es.shutdown();

    }

}
class MyThread implements Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+" -线程启动");
    }
}
